#define  _CRT_SECURE_NO_WARNINGS 1


#include <stdio.h>


#include<stdio.h>
int main()
{
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int a[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    int Swap(int*, int n, int m);
    Swap(a, n, m);
    for (int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
    return 0;
}
int Swap(int a[100], int n, int m)
{
    int b[n];
    for (int i = 0; i < n; i++)
    {
        b[i] = a[i];
    }
    int j = m;
    for (int i = 0; i < m; i++, j--)
    {
        a[i] = b[n - j];
    }
    int i, k;
    for (i = n - m+1, k = 0; i < n; i++, k++)
    {
        a[i] = b[k];
    }
    return 0;
}